import React from 'react';
import DataTable from 'components/DataTable';
import Icon from 'components/Icon';
import Button from 'components/Button';
import { Link } from 'dva/router';

export default (self, category) => [
  {
    title: '名称',
    name: 'name',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '编号',
    name: 'no',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '类别',
    name: 'categoryId',
    tableItem: {
      render: (text, record) => (
        record.category && record.category.name
      )
    },
    formItem: {},
    searchItem: {}
  },
  {
    title: '风格',
    name: 'style',
    tableItem: {
      render: (text, record) => (
        record.style && record.style.name
      )
    },
    formItem: {},
    searchItem: {}
  },
  {
    title: '尺寸',
    name: 'size',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '材质',
    name: 'texture',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '厂家',
    name: 'factory',
    tableItem: {
      render: (text, record) => (
        record.factory.name
      )
    },
    formItem: {},
    searchItem: {}
  },
  {
    title: '售价',
    name: 'price',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '进价',
    name: 'inPrice',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '备注',
    name: 'remark',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '售出数量',
    name: 'saleAmt',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '库存状态',
    name: 'status',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '售卖状态',
    name: 'saleStatus',
    tableItem: {},
    formItem: {},
    searchItem: {}
  },
  {
    title: '操作',
    tableItem: {
      width: 180,
      render: (text, record) => (
        <DataTable.Oper>
          <Button tooltip="修改" onClick={e => {console.log(self.onUpdate);self.onUpdate(record);}}>
            <Icon type="edit" />
          </Button>
          <Button tooltip="删除" onClick={e => self.onDelete(record)}>
            <Icon type="trash" />
          </Button>
          <Button tooltip="跳转到新路由">
            <Link to={"/crud/detail?id=" + record.id}>
              <Icon type="link" antd />
            </Link>
          </Button>
        </DataTable.Oper>
      )
    }
  }
];
